<!--
    Think.get.type == 1  单选
    Think.get.type == 2  多选
    Think.get.type == 3  优惠卷专用

    return {
        user_id:1,
        user_name:昵称,
        user_phone:手机,
        user_email:邮箱
    }

-->


<div class="bjui-pageHeader">
    <div class="pull-right">
        <eq name="Think.request.type" value="2">
            <input type="checkbox" name="lookupType" value="1" data-toggle="icheck" data-label="追加" checked>
            <button type="button" class="btn-blue" data-toggle="lookupback" data-lookupid="ids" data-warn="请至少选择一项" data-icon="check-square-o">选择勾选</button>
        </eq>
        <eq name="Think.request.type" value="3">
            <a href="{:U('Forms/send_user_coupon',array('tid'=>I('id')))}" class="btn btn-default" data-toggle="doajaxchecked" data-callback="callbackRefres" data-confirm-msg="把优惠卷发给您所勾选的用户???" data-idname="id" data-group="ids">选中发放</a>
        </eq>
    </div>
    <form id="pagerForm" data-toggle="ajaxsearch" data-loadingmask="true" action="{:U('menber')}" method="post">
        <input type="hidden" name="pageSize" value="{:I('param.pageSize')}" />
        <input type="hidden" name="pageCurrent" value="{:I('param.pageCurrent')}" />
        <input type="hidden" name="orderField" value="{:I('param.orderField')}" />
        <input type="hidden" name="orderDirection" value="{:I('param.orderDirection')}" />
        <input type="hidden" name="type" value="{:I('type')}"/>
        <div class="bjui-searchBar">
            <label>关键字:</label>
            <input type="text" name="name" placeholder="昵称,手机,邮箱" value="{:I('name')}"/>
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            <a class="btn btn-orange" href="javascript:;" data-toggle="reloadsearch" data-clear-query="true" data-icon="undo">清空查询 </a>
        </div>
    </form>
</div>
<div class="bjui-pageContent tableContent">
    <eq name="Think.request.type" value="3">
        <div class="panel panel-default" style="margin-bottom: 0;">
            <div class="panel-body">
               <div class="form-group">
                   <label class="x100">按等级发放:</label>
                   <select name="groupid" data-toggle="selectpicker" class="sel-leve" data-id="{:I('id')}">
                       <option value>--请选择--</option>
                       <volist name="group" id="go">
                       <option value="{$go.id}">{$go.name}</option>
                       </volist>
                   </select>
                   <button type="button" class="btn-blue group-send" >发放</button>
               </div>
            </div>
        </div>
    </eq>
    <table class="table table-bordered table-hover table-striped table-top" data-selected-multi="false">
        <thead>
        <tr>
            <neq name="Think.request.type" value="1">
                <th width="26"><input type="checkbox" class="checkboxCtrl" data-group="ids" data-toggle="icheck"></th>
            </neq>
            <th>昵称</th>
            <th>手机</th>
            <th>邮箱</th>
            <th>等级</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        <volist name="user" id="vo">
        <tr>
            <eq name="Think.request.type" value="2">
                <td width="26"><input type="checkbox" value="{user_id:<php>echo $vo['id']</php>,user_name:'<php>echo $vo['name']</php>',user_phone:'<php>echo $vo['mobile']</php>',user_email:'<php>echo $vo['email']</php>'}" class="checkboxCtrl" name="ids" data-toggle="icheck"></td>
            </eq>
            <eq name="Think.request.type" value="3">
                <td width="26"><input type="checkbox" value="{$vo.id}" name="ids" data-toggle="icheck"></td>
            </eq>
            <td>{$vo.name}</td>
            <td>{$vo.mobile}</td>
            <td>{$vo.email}</td>
            <td>{$vo.groupname}</td>
            <td>
                <eq name="Think.request.type" value="3">
                    <button type="button" class="btn-blue" data-toggle="doajax" data-confirm-msg="你确定要给用户发放优惠券吗？" data-url="{:U('Forms/send_user_coupon',array('tid'=>I('id'),'id'=>$vo['id']))}" data-type="get">发放</button>
                <else />
                    <button type="button" class="btn-green" data-toggle="lookupback" data-args="{user_id:<php>echo $vo['id']</php>,user_name:'<php>echo $vo['name']</php>',user_phone:'<php>echo $vo['mobile']</php>',user_email:'<php>echo $vo['email']</php>'}">选</button>
                </eq>
            </td>
        </tr>
        </volist>
        </tbody>
    </table>
</div>
<script>
    $('.group-send').click(function () {
        var v = $('.sel-leve').val();
        var tid = $(".sel-leve").attr("data-id");
        if( v ){

            $(this).bjuiajax('doajax', {
                url:"{:U('Forms/send_user_group_coupon')}",
                data:{lv:v,tid:tid},
                confirmMsg:"确认要把优惠卷发给整个等级组?"
            });

        }else{
            $(this).alertmsg('error', "请选择用记等级");
        }
    });
</script>
<include file="Common/footer" ftype="page" />